home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / gs261src.zip / gspaint.c < prev    next >
C/C++ Source or Header  |  1993-05-13  |  3KB  |  105 lines

  1. /* Copyright (C) 1989, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gspaint.c */
  20. /* Painting procedures for Ghostscript library */
  21. #include "gx.h"
  22. #include "gpcheck.h"
  23. #include "gserrors.h"
  24. #include "gxfixed.h"
  25. #include "gxmatrix.h"            /* for gs_state */
  26. #include "gspaint.h"
  27. #include "gzpath.h"
  28. #include "gzstate.h"
  29. #include "gzdevice.h"
  30. #include "gzcolor.h"
  31. #include "gxcpath.h"
  32. #include "gxdevmem.h"
  33. #include "gximage.h"
  34.  
  35. /* Erase the page */
  36. int
  37. gs_erasepage(gs_state *pgs)
  38. {    device *pdev = pgs->device;
  39.     gx_device *dev = pdev->info;
  40.     return (*dev->procs->fill_rectangle)(dev, 0, 0, dev->width, dev->height, pdev->white);
  41. }
  42.  
  43. /* Fill using the winding number rule */
  44. int
  45. gs_fill(gs_state *pgs)
  46. {    int code;
  47.     /* If we're inside a charpath, just merge the current path */
  48.     /* into the parent's path. */
  49.     if ( pgs->in_charpath )
  50.         code = gx_path_add_path(pgs->show_gstate->path, pgs->path);
  51.     else
  52.        {    gx_color_load(pgs->dev_color, pgs);
  53.         code = gx_fill_path(pgs->path, pgs->dev_color, pgs,
  54.                     gx_rule_winding_number, fixed_0);
  55.         if ( !code ) gs_newpath(pgs);
  56.        }
  57.     return code;
  58. }
  59.  
  60. /* Fill using the even/odd rule */
  61. int
  62. gs_eofill(gs_state *pgs)
  63. {    int code;
  64.     /* If we're inside a charpath, just merge the current path */
  65.     /* into the parent's path. */
  66.     if ( pgs->in_charpath )
  67.         code = gx_path_add_path(pgs->show_gstate->path, pgs->path);
  68.     else
  69.        {    gx_color_load(pgs->dev_color, pgs);
  70.         code = gx_fill_path(pgs->path, pgs->dev_color, pgs,
  71.                     gx_rule_even_odd, fixed_0);
  72.         if ( !code ) gs_newpath(pgs);
  73.        }
  74.     return code;
  75. }
  76.  
  77. /* Stroke the current path */
  78. int
  79. gs_stroke(gs_state *pgs)
  80. {    int code;
  81.     /* If we're inside a charpath, just merge the current path */
  82.     /* into the parent's path. */
  83.     if ( pgs->in_charpath )
  84.         code = gx_path_add_path(pgs->show_gstate->path, pgs->path);
  85.     else
  86.        {    gx_color_load(pgs->dev_color, pgs);
  87.         code = gx_stroke_fill(pgs->path, pgs);
  88.         if ( !code ) gs_newpath(pgs);
  89.        }
  90.     return code;
  91. }
  92.  
  93. /* Compute the stroked outline of the current path */
  94. int
  95. gs_strokepath(gs_state *pgs)
  96. {    gx_path spath;
  97.     int code;
  98.     gx_path_init(&spath, pgs->memory_procs);
  99.     code = gx_stroke_add(pgs->path, &spath, pgs);
  100.     if ( code < 0 ) return code;
  101.     gx_path_release(pgs->path);
  102.     *pgs->path = spath;
  103.     return 0;
  104. }
  105.